package com.weilele.leisure.time.ui.holder


import android.view.View
import com.weilele.leisure.time.databinding.HolderLoadingBinding
import com.weilele.mvvm.adapter.MvvmHolder
import com.weilele.mvvm.adapter.mvvmRcvAdapter
import com.weilele.mvvm.utils.activity.setGone
import com.weilele.mvvm.utils.activity.textFrom


class LoadingHolder : MvvmHolder<LoadingHolder.Bean, HolderLoadingBinding> {
    companion object {
        fun toAdapter() = mvvmRcvAdapter(LoadingHolder::class.java,
            { old, new -> old == new },
            { old, new -> old?.text == new?.text && old?.showProgress == new?.showProgress }
        )
    }

    constructor(binding: HolderLoadingBinding) : super(binding)
    constructor(itemView: View) : super(itemView)

    data class Bean(
        var text: String?,
        var showProgress: Boolean
    )

    override fun bindData(data: Bean) {
        mBinding.tvText.textFrom(data.text)
        mBinding.progress.setGone(data.showProgress)
    }
}